package com.eagle.functioninterface;

import org.junit.Test;

import java.util.function.DoubleBinaryOperator;
import java.util.function.IntBinaryOperator;
import java.util.function.LongBinaryOperator;

/**
 * 这类函数式接口的命名规则是:入参和出参类型+BinaryOperator
 * {@link java.util.function.IntBinaryOperator}
 * {@link java.util.function.LongBinaryOperator}
 * {@link java.util.function.DoubleBinaryOperator}
 *
 * @author qinlinsen
 */
public class OutPutBinaryOperatorTest14 {
    @Test
    public void testIntBinaryOperator() {
        final IntBinaryOperator f = (x, y) -> x + y;
        final int result = f.applyAsInt(3, 5);
        System.out.println(result);
    }

    @Test
    public void testLongBinaryOperator() {
        final LongBinaryOperator f = (x, y) -> x * y;
        final long result = f.applyAsLong(3L, 5L);
        System.out.println(result);
    }

    @Test
    public void testDoubleBinaryOperator() {
        final DoubleBinaryOperator f = (x, y) -> x - y;
        final double result = f.applyAsDouble(3d, 4d);
        System.out.println(result);
    }
}
